package cn.ywsj.ywsjmidtier.controller;

import cn.ywsj.ywsjmidtier.entity.VO.ThOrderListQueryVo;
import cn.ywsj.ywsjmidtier.service.WechatAlipayFeign;
import cn.ywsj.ywsjmidtier.utils.JsonObjectUtil;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import javax.servlet.http.HttpServletRequest;

/**
 * @ClassName : WechatAlipayController
 * @Author : Lenovo
 * @Date: 2021/7/23 11:14
 * @Description :
 */
@RestController
@RequestMapping("/wechat/alipayment/*")
public class WechatAlipayController {
    @Autowired
    private WechatAlipayFeign wechatAlipayFeign;
    @PostMapping("/processmerge")
    public String presellProcessMerge(ThOrderListQueryVo orderListQueryVo, HttpServletRequest request, RedirectAttributes attr){
        JSONObject jsonObject = JsonObjectUtil.ObjectToJson(orderListQueryVo);
        return wechatAlipayFeign.presellProcessMerge(jsonObject,request,attr);
    }
    @PostMapping("/process")
    public String presellProcess(ThOrderListQueryVo orderListQueryVo,HttpServletRequest request, RedirectAttributes attr){
        JSONObject jsonObject = JsonObjectUtil.ObjectToJson(orderListQueryVo);
        return wechatAlipayFeign.presellProcess(jsonObject,request,attr);
    }
    @PostMapping("/topay")
    public String onlinePaymentDirect(ThOrderListQueryVo orderListQueryVo){
        JSONObject jsonObject = JsonObjectUtil.ObjectToJson(orderListQueryVo);
        return wechatAlipayFeign.onlinePaymentDirect(jsonObject);
    }
    @PostMapping("/callbackurl")
    public String directReturnUrl(HttpServletRequest request){
       return wechatAlipayFeign.directReturnUrl(request);
    }
    @PostMapping("/notifyurlmerge")
    public String directNotifyUrl(HttpServletRequest request){
        return wechatAlipayFeign.directNotifyUrl(request);
    }
    @PostMapping("/notifyurl")
    public String directNotifyUrlMerge(HttpServletRequest request){
        return wechatAlipayFeign.directNotifyUrlMerge(request);
    }
    @GetMapping("/notifyurlcs")
    public String ceishi(){
      return wechatAlipayFeign.ceishi();
    }
}
